package o;

import android.app.Notification;
import android.app.Notification.Builder;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseArray;
import androidx.annotation.RequiresApi;
import androidx.core.app.NotificationCompat.Action;
import androidx.core.app.RemoteInput;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@RequiresApi(16)
public class fn {
    private static Field ˊ;
    private static final Object ˋ = new Object();
    private static final Object ˎ = new Object();
    private static boolean ॱ;

    public static SparseArray<Bundle> ॱ(List<Bundle> list) {
        SparseArray<Bundle> sparseArray = null;
        int size = list.size();
        for (int i = 0; i < size; i++) {
            Bundle bundle = (Bundle) list.get(i);
            if (bundle != null) {
                if (sparseArray == null) {
                    sparseArray = new SparseArray();
                }
                sparseArray.put(i, bundle);
            }
        }
        return sparseArray;
    }

    public static Bundle ˋ(Notification notification) {
        synchronized (ˋ) {
            if (ॱ) {
                return null;
            }
            try {
                if (ˊ == null) {
                    Field declaredField = Notification.class.getDeclaredField("extras");
                    if (Bundle.class.isAssignableFrom(declaredField.getType())) {
                        declaredField.setAccessible(true);
                        ˊ = declaredField;
                    } else {
                        Log.e("NotificationCompat", "Notification.extras field is not of type Bundle");
                        ॱ = true;
                        return null;
                    }
                }
                Bundle bundle = (Bundle) ˊ.get(notification);
                if (bundle == null) {
                    bundle = new Bundle();
                    ˊ.set(notification, bundle);
                }
                return bundle;
            } catch (Throwable e) {
                Log.e("NotificationCompat", "Unable to access notification extras", e);
                ॱ = true;
                return null;
            } catch (Throwable e2) {
                Log.e("NotificationCompat", "Unable to access notification extras", e2);
                ॱ = true;
                return null;
            }
        }
    }

    public static Bundle ˋ(Builder builder, Action action) {
        builder.addAction(action.ˏ(), action.ˊ(), action.ˎ());
        Bundle bundle = new Bundle(action.ˋ());
        if (action.ॱॱ() != null) {
            bundle.putParcelableArray("android.support.remoteInputs", ˏ(action.ॱॱ()));
        }
        if (action.ᐝ() != null) {
            bundle.putParcelableArray("android.support.dataRemoteInputs", ˏ(action.ᐝ()));
        }
        bundle.putBoolean("android.support.allowGeneratedReplies", action.ॱ());
        return bundle;
    }

    public static Bundle ˏ(Action action) {
        Bundle bundle;
        Bundle bundle2 = new Bundle();
        bundle2.putInt("icon", action.ˏ());
        bundle2.putCharSequence("title", action.ˊ());
        bundle2.putParcelable("actionIntent", action.ˎ());
        if (action.ˋ() != null) {
            bundle = new Bundle(action.ˋ());
        } else {
            bundle = new Bundle();
        }
        bundle.putBoolean("android.support.allowGeneratedReplies", action.ॱ());
        bundle2.putBundle("extras", bundle);
        bundle2.putParcelableArray("remoteInputs", ˏ(action.ॱॱ()));
        bundle2.putBoolean("showsUserInterface", action.ʼ());
        bundle2.putInt("semanticAction", action.ʻ());
        return bundle2;
    }

    private static Bundle ˊ(RemoteInput remoteInput) {
        Bundle bundle = new Bundle();
        bundle.putString("resultKey", remoteInput.ˊ());
        bundle.putCharSequence("label", remoteInput.ˎ());
        bundle.putCharSequenceArray("choices", remoteInput.ˏ());
        bundle.putBoolean("allowFreeFormInput", remoteInput.ˋ());
        bundle.putBundle("extras", remoteInput.ʼ());
        Set<String> ॱ = remoteInput.ॱ();
        if (!(ॱ == null || ॱ.isEmpty())) {
            ArrayList arrayList = new ArrayList(ॱ.size());
            for (String add : ॱ) {
                arrayList.add(add);
            }
            bundle.putStringArrayList("allowedDataTypes", arrayList);
        }
        return bundle;
    }

    private static Bundle[] ˏ(RemoteInput[] remoteInputArr) {
        if (remoteInputArr == null) {
            return null;
        }
        Bundle[] bundleArr = new Bundle[remoteInputArr.length];
        for (int i = 0; i < remoteInputArr.length; i++) {
            bundleArr[i] = ˊ(remoteInputArr[i]);
        }
        return bundleArr;
    }
}
